<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('广告位管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <input type="hidden" id="platform" name="platform" th:value="${platform}"/>
                            <li>
                                <p>应用ID：</p>
                                <select id="appId" name="appId" th:with="type=${@dict.getType('kkad_app_id')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>ID：</p>
                                <input type="text" name="code"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="kkad:adplace:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="kkad:adplace:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="kkad:adplace:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('kkad:adplace:edit')}]];
        var removeFlag = [[${@permission.hasPermi('kkad:adplace:remove')}]];
        var appIdDatas = [[${@dict.getType('kkad_app_id')}]];
        var statusDatas = [[${@dict.getType('common_status')}]];
        var typeDatas = [[${@dict.getType('kkad_ad_type')}]];
        var thirdTypeDatas = [[${@dict.getType('kkad_third_type')}]];
        var shieldStrategyDatas = [[${@dict.getType('kkad_shield_strategy')}]];
        var prefix = ctx + "kkad/adplace";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "广告位管理",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'appId', 
                    title : '应用ID',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(appIdDatas, value);
                    }
                },
                {
                    field : 'code', 
                    title : 'ID'
                },
                {
                    field : 'type', 
                    title : '广告类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field : 'width', 
                    title : '宽高',
                   	formatter: function(value, row, index) {
                       return row.width + '*' + row.height
                    }
                },
                {
                    field : 'status', 
                    title : '启用',
                    formatter: function(value, row, index) {
                    	if(value == 1){
                      	   return '<i class=\"fa fa-toggle-on text-info fa-2x\" )"></i>'
                        }else{
                      	   return '<i class=\"fa fa-toggle-off text-info fa-2x\" )"></i>'
                        }
                    }
                },
                {
                    field : 'openThird', 
                    title : '启用第三方',
                    formatter: function(value, row, index) {
                    	if(value == 1){
                      	   return '<i class=\"fa fa-toggle-on text-info fa-2x\" )"></i>'
                        }else{
                      	   return '<i class=\"fa fa-toggle-off text-info fa-2x\" )"></i>'
                        }
                    }
                },
                {
                    field : 'thirdType', 
                    title : '第三方类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(thirdTypeDatas, value);
                    }
                },
                {
                    field : 'shieldStrategy',
                    title : '第三方屏蔽策略',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(shieldStrategyDatas, value);
                    }
                },
                {
                    field : 'shieldThirdType',
                    title : '屏蔽后第三方类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(thirdTypeDatas, value);
                    }
                },
                {
                    field : 'remark', 
                    title : '说明'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        if(row.status == 0){
                           //actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function add(){
        	 var appId = $("#appId option:selected").val();
        	 var platform = $("#platform").val();
        	 $.operate.add(appId + ":" + platform);
        }
        
    </script>
</body>
</html>